home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / mail / YAMscripts.lha / FixQuotes.rexx < prev    next >
OS/2 REXX Batch file  |  1997-05-25  |  2KB  |  52 lines

  1. /* FixQuotes.rexx 1.0 - 15-Mar-97
  2. ** Removes those annoying squares from a message which are displayed if your font
  3. ** doesn't support all characters.
  4. ** Check http://www.utu.fi/~knikulai/ARexx.html for other useful scripts! */
  5.  
  6. options results
  7. address 'YAM'
  8. 'GetMailInfo File'
  9.  
  10. if rc>0 then do /* You screwed up! */
  11.     'Request "You need to select a message first!" "_Abort script"'
  12.     exit /* quit script */
  13.     end  /* not the script, the do after then... */
  14.  
  15. filename=result
  16. if open(in,filename,'r') then do
  17.     if open(out,'t:tmp','w') then do      /* try to open a temp file */
  18.         do while ~eof(in)             /* convert whole message */
  19.             r=readln(in)          /* read a line */
  20.             r=change(r,'=92',"'") /* I've no idea what this */
  21.             r=change(r,'92'x,"'") /* char is called... :-)  */
  22.             r=change(r,'=93','"') /* begin quote */
  23.             r=change(r,'93'x,'"') /* so is this */
  24.             r=change(r,'=94','"') /* end quote */
  25.             r=change(r,'94'x,'"') /* same here */
  26.             call writeln(out,r)
  27.             end
  28.         call close(out)
  29.         end
  30.     else do
  31.         'Request "Can not write temp file!" "_Abort script"'    /* Bad luck! */
  32.         exit
  33.         end
  34.     call close(in)
  35.     address command 'copy >nil: t:tmp' filename
  36.     address command 'delete >nil: t:tmp'
  37.     'Request "All quotes converted." "Ok"'
  38.     end
  39. else
  40.     'Request "Can not open message!" "_Abort script"'/* This shouldn't ever happen */
  41. exit    /* That's all folks! */
  42.  
  43. change:
  44. parse arg s,o,n         /* Args: string, old chars, new chars */
  45. do while pos(o,s)>0        /* do while there are old chars left */
  46.     p=pos(o,s)        /* find the position */
  47.     b=left(s,p-1)        /* store the beginning of line */
  48.     e=substr(s,p+length(o))    /* and the end of line */
  49.     s=b || n || e        /* create new and improved string */
  50.     end
  51. return s            /* Return the result */
  52.